//-----------------------------------------------------------------------
// <copyright file="EventBrokerStrategyBase.cs" company="iron9light">
//      Copyright (c) iron9light. All rights reserved.
// </copyright>
// <author>iron9light</author>
//-----------------------------------------------------------------------

namespace EventBrokerExtension
{
    using System;

    using EventBroker;

    using Microsoft.Practices.ObjectBuilder2;

    public abstract class EventBrokerStrategyBase : BuilderStrategy
    {
        /// <summary>
        /// Gets the broker.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns>The event broker</returns>
        protected static IEventBroker GetBroker(IBuilderContext context)
        {
            IEventBroker broker = context.Locator.Get<IEventBroker>(typeof(IEventBroker));
            if (broker == null)
            {
                throw new InvalidOperationException("No event broker available");
            }

            return broker;
        }
    }
}